package com.dick.base.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dick.base.model.BusinessOrder;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.Set;

@Repository
public interface BusinessOrderMapper extends BaseMapper<BusinessOrder> {
    @Update("update business_order o left join (SELECT order_id, min(status) AS min_status FROM business_order_item where order_id = #{id}) " +
            "item on o.id = item.order_id set o.status = item.min_status, o.update_time = now() where o.id = #{id}")
    int updateStatus(@Param("id") Long id);
}
